package edu.mse.camel.client.session.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class CreateSessionDialog extends DefaultDialog {

	private Text sessionNameField;
	private StyledText sessionDescField;
	private String sessionName;
	private String sessionDesc;
	
	protected CreateSessionDialog(Shell parentShell) {
		super(parentShell);
	}

	@Override
	protected void buttonPressed(int buttonId) {
		if(buttonId == 0)
		{
			sessionName = sessionNameField.getText();
			sessionDesc = sessionDescField.getText();
		}
		else
		{
			sessionName = "";
			sessionDesc = "";
		}

		super.buttonPressed(buttonId);
	}

	@Override
	protected Control createDialogArea(Composite parent) {
		
		Composite comp = (Composite) super.createDialogArea(parent);
		comp.getShell().setText(DialogMessages.CreateSessionDialog_Title);
		
		GridLayout layout = (GridLayout) comp.getLayout();
	    layout.numColumns = 2;

	    Label sessionNameLabel = new Label(comp, SWT.RIGHT);
	    sessionNameLabel.setText("Session Name: ");

	    sessionNameField = new Text(comp, SWT.SINGLE);
	    GridData data = new GridData(GridData.FILL_HORIZONTAL);
	    sessionNameField.setLayoutData(data);

	    Label sessionDescLabel = new Label(comp, SWT.RIGHT);
	    sessionDescLabel.setText("Session Decsription: ");

	    sessionDescField = new StyledText(comp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
	    data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
	    sessionDescField.setLayoutData(data);
	    
	    return comp;
	}

	public String getSessionName() {
		return sessionName;
	}

	public String getSessionDesc() {
		return sessionDesc;
	}	
}
